home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
dtk_demo.zip
/
TIMEFORM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-12
|
2KB
|
79 lines
/* TIMEFORM.C
* last mod.: 10-AUG-91
*/
/* this displays a given time 27 times
* using different time format parameters
*/
#include <STDIO.H>
#include <STDLIB.H>
#include <STRING.H>
#include <L_TIME.H>
#include <L_STR.H>
char *usage = "\nUse TIMEFORM hour minute second hsecond\n";
char time_str[32];
Time t;
Time_format tf;
int n=0;
void main(int argc, char *argv[]);
void display_time(void);
/*-----------------------------*/
void main(int argc, char *argv[])
{
if ( argc < 3 )
{
printf(usage);
exit(0);
}
t.hour = (Uchar)atoi(argv[1]);
t.minute = (Uchar)atoi(argv[2]);
t.second = (Uchar)atoi(argv[3]);
t.hsecond = (Uchar)atoi(argv[4]);
if ( !time_valid(&t) )
{
printf("\nInvalid time.\n");
exit(1);
}
set_time_format_default(&tf);
for ( tf.components=0; tf.components<6; tf.components++ )
{
if ( tf.components >= 3 )
display_time();
else
{
for ( tf.hr_justified=FALSE; tf.hr_justified<=TRUE; tf.hr_justified++ )
{
for ( tf.style=0; tf.style<2; tf.style++ )
{
if ( tf.style==0 && tf.components <= 2 )
{
for ( tf.am_pm=0; tf.am_pm<3; tf.am_pm++ )
display_time();
}
else
display_time();
}
}
}
}
}
/*-------------------*/
void display_time(void)
{
time_to_str(&t,&tf,time_str);
pad_on_left(time_str,' ',19);
printf("%s",time_str);
if ( ++n%4 )
putchar(' ');
else
putchar('\n');
}